import { request } from '@/service/request';
import { ConfigurationTypeEnum } from '@/constants/business';

/**
 * 获取配置列表
 */
export function getConfigurationList() {
  return request<Api.Configure.Info[]>({
    url: '/Configs/List'
  });
}

/**
 * 添加配置
 * @param data
 */
export function addConfig(data: Api.Configure.AddOrEdit) {
  return request<number>({
    url: '/Configs',
    method: 'post',
    data
  });
}

/**
 * 更新配置
 * @param data
 */
export function updateConfig(data: Api.Configure.AddOrEdit) {
  return request<number>({
    url: '/Configs',
    method: 'put',
    data
  });
}

/**
 * 删除配置
 * @param id
 */
export function deleteConfig(id: string) {
  return request<number>({
    url: `/Configs/${id}`,
    method: 'delete'
  });
}

/**
 * 获取配置类型
 * @constructor
 */
export function getConfigTypeList() {
  return request<Api.Basics.SelectItem<number>[]>({
    url: '/Configs/Type'
  });
}

/**
 * 获取类型下拉框
 * @constructor
 */
export function getConfigTypeSelectList(type: ConfigurationTypeEnum) {
  return request<Api.Basics.SelectItem<string>[]>({
    url: '/Configs/TypeList',
    params: {
      type
    }
  });
}
